﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Collections;
using GMS.BIZ;

namespace Web.Paper
{
    public partial class WebForm8 : System.Web.UI.Page
    {
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            if (!((Account)Session["Account"]).RoleCurrent.Equals('c')) Response.Redirect("Default.aspx");
            ClassTeacher myClassTeacher = new ClassTeacher(((ClassTeacher)Session["ClassTeacher"]).TeacherId);
            if (!IsPostBack)
            {
                ArrayList arraylist = new ArrayList();
                
                arraylist = myClassTeacher.Classes.GetList();
                if (arraylist.Count!=0)
                {
                    for (int i = 0; i < arraylist.Count; i++)
                    {
                        ListItem myListItem = new ListItem();
                        myListItem.Text = arraylist[i].ToString();
                        myListItem.Value = myListItem.Text;
                        DropDownList_class.Items.Add(myListItem);
                    }
                }
                else
                    DropDownList_class.SelectedItem.Text = "空";
            }
            ClassInfo myClassInfo = new ClassInfo(DropDownList_class.SelectedValue);
            DataSet ds = myClassInfo.GetStudentsDataSetWithDefenseInfo();
            if (ds.Tables[0].Rows.Count!=0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    ds.Tables[0].Rows[i]["def_teacher"] = Staff.GetName(ds.Tables[0].Rows[i]["def_teacher"].ToString());
                    ds.Tables[0].Rows[i]["def_assistant"] = Staff.GetName(ds.Tables[0].Rows[i]["def_assistant"].ToString());
                }
                GridView_StuDefense.DataSource = ds;
                GridView_StuDefense.DataBind();
            }
            else 
                Label_NoData.Text = "该班级没有学生答辩信息";     
        }

        protected void GridView_StuDefense_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            ClassTeacher myClassTeacher = new ClassTeacher(((ClassTeacher)Session["ClassTeacher"]).TeacherId);
            ClassInfo myClassInfo = new ClassInfo(DropDownList_class.SelectedValue);
          
                GridView_StuDefense.DataSource = myClassInfo.GetStudentsDataSetWithDefenseInfo();
                GridView_StuDefense.DataBind();
     
        }
    }
}
